package com.qidianit.mes.pro.controller;

import com.github.pagehelper.PageInfo;
import com.qidianit.mes.pojo.Result;
import com.qidianit.mes.pojo.pro.MaterialBom;
import com.qidianit.mes.pro.service.MaterialBomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description:
 * @Author: YanJiRan
 * @Date: 2025/9/23 - 上午11:33
 */
@RestController
@RequestMapping("/materialBom")
public class MaterialBomController {
    @Autowired
    private MaterialBomService materialBomService;

    @GetMapping("/page")
    public Result<PageInfo<MaterialBom>> list(MaterialBom materialBom, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int size){
        return materialBomService.selectList(materialBom,page,size);
    }

    @PostMapping("/add")
    public Result<MaterialBom> save(@RequestBody MaterialBom materialBom){
        return materialBomService.saveMaterialBom(materialBom);
    }

    @GetMapping("{id}")
    public Result<MaterialBom> getByCode(@PathVariable("id") Long id){
        return materialBomService.selectById(id);
    }

    @PutMapping("/update")
    public Result update(@RequestBody MaterialBom materialBom){
        return materialBomService.updateById(materialBom);
    }

    @DeleteMapping("/delete/{id}")
    public Result deleteById(@PathVariable("id") Long id){
        return materialBomService.deleteById(id);
    }

    @DeleteMapping("/batchDelete")
    public Result batchDelete(Long[] id){
        return materialBomService.batchDelete(id);
    }
}
